<template>
  <el-row>
    <!--      风险识别-星合星探-->
    <el-card v-if="riskIdentificationData.length > 0">
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.riskIdentification.title') }}
          </template>
          <table>
            <tr>
              <td>{{ $t('authModule.riskIdentification.type') }}</td>
              <td>{{ $t('authModule.riskIdentification.reportResults') }}</td>
              <td>{{ $t('authModule.riskIdentification.selectType') }}</td>
              <td>{{ $t('authModule.riskIdentification.updateTime') }}</td>
            </tr>
            <tr v-for="(item, index) in riskIdentificationData" :key="index">
              <td>{{ item['riskType'] }}</td>
              <td :style="{color:item['reportResult']==='HIT' ? 'red' :''}">{{ item['reportResult'] }}</td>
              <td>{{ $t('authModule.riskIdentification.source')[item['dataSource']] }}</td>
              <td>{{ item['createTime'] }}</td>
            </tr>
          </table>
        </el-collapse-item>
      </el-collapse>
    </el-card>
    <!--      评分查询-advance.ai-->
    <el-card v-if="riskIdentificationData.length > 0">
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.scoringQuery.title') }}
          </template>
          <table>
            <tr>
              <td>{{ $t('authModule.scoringQuery.creditScore') }}</td>
              <td>
                <el-button type="text" @click="getCreditScore">
                  {{ $t('authModule.scoringQuery.click') }}
                </el-button>
                <el-button v-if="creditScore !== null" type="text">
                  {{ creditScore }}
                </el-button>
              </td>
              <td>{{ $t('authModule.scoringQuery.telecommunications') }}</td>
              <td>
                <el-button type="text" @click="getTelecomScore">
                  {{ $t('authModule.scoringQuery.click') }}
                </el-button>
                <el-button v-if="telecomScore !== null" type="text">
                  {{ telecomScore }}
                </el-button>
              </td>
            </tr>
            <tr v-if="advanceData && advanceData['adCreditScoreVOS'] && advanceData['adCreditScoreVOS'].length > 0">
              <td>{{ $t('authModule.scoringQuery.lastQuery') }}</td>
              <td>
                {{ advanceData['adCreditScoreVOS'][0]['lastQueryScore'] }}
                {{ advanceData['adCreditScoreVOS'][0]['lastQueryDateStr'] }}
              </td>
              <td>{{ $t('authModule.scoringQuery.lastQuery') }}</td>
              <td>
                {{ advanceData['adTelecomScoreVOS'][0]['lastQueryScore'] }}
                {{ advanceData['adTelecomScoreVOS'][0]['lastQueryDateStr'] }}</td>
            </tr>
            <tr v-for="(item, index) in $t('authModule.scoringQuery.table')" :key="index">
              <td colspan="2">{{ item['name'] }}</td>
              <td colspan="2">
                <span v-if="advanceData && advanceData['adCreditScoreVOS'] && advanceData['adCreditScoreVOS'].length > 0">
                  {{ advanceData['adCreditScoreVOS'][0][item['reflect']] }}
                </span>
              </td>
            </tr>
          </table>
        </el-collapse-item>
      </el-collapse>
    </el-card>
    <!--      评分查询-冰鉴-->
    <el-card>
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.bingJian.title') }}
          </template>
          <table>
            <tr>
              <td>{{ $t('authModule.bingJian.fraction') }}</td>
              <td>
                <el-button type="text" @click="getBingjian(1)">
                  {{ $t('authModule.bingJian.click') }}
                </el-button>
              </td>
              <td>{{ $t('authModule.bingJian.lastQuery') }}</td>
              <td>
                <span v-if="bingjian && bingjian['bingjian_multi_score'] !== null">{{ bingjian['bingjian_multi_score'] }}</span>
                <span v-if="bingjian && bingjian['createTime']" class="left">{{ bingjian['createTime'] }}</span>
              </td>
            </tr>
            <tr v-if="bingjian && bingjian['errorMessage']">
              <td colspan="4">
                {{ bingjian['errorMessage'] }}
              </td>
            </tr>
          </table>
          <table v-if="bingjian && !bingjian['errorMessage']" style="margin-top: 10px">
            <tr v-for="(item, index) in $t('authModule.bingJian.feature')" :key="index">
              <td>
                {{ item['reflect'] }}
              </td>
              <td>
                <span v-if="bingjian && bingjian[item['reflect']] !== null">{{ bingjian[item['reflect']] }}</span>
              </td>
            </tr>
          </table>
        </el-collapse-item>
      </el-collapse>
    </el-card>
    <!--        评分查询-izi-->
    <el-card>
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.izi.title') }}
          </template>
          <el-row :gutter="20">
            <el-col :span="8">
              <table>
                <tr>
                  <td>{{ $t('authModule.izi.skorBulls') }}</td>
                  <td>
                    <el-button type="text" @click="getInquiriesScore(1)">
                      {{ $t('authModule.izi.click') }}
                    </el-button>
                  </td>
                </tr>
                <tr>
                  <td>{{ $t('authModule.izi.lastQuery') }}</td>
                  <td>{{ inquiriesScoreData && inquiriesScoreData['createTime'] ? inquiriesScoreData['createTime'] : '' }}</td>
                </tr>
                <tr>
                  <td>status</td>
                  <td>{{ inquiriesScoreData && inquiriesScoreData['status'] ? inquiriesScoreData['status'] : '' }}</td>
                </tr>
                <tr>
                  <td>message</td>
                  <td>{{ inquiriesScoreData && inquiriesScoreData['message'] ? inquiriesScoreData['message'] : '' }}</td>
                </tr>
              </table>
            </el-col>
            <el-col :span="8">
              <table>
                <tr>
                  <td>{{ $t('authModule.izi.creditFeature') }}</td>
                  <td>
                    <el-button type="text" @click="getCreditFeature(1)">
                      {{ $t('authModule.izi.click') }}
                    </el-button>
                  </td>
                </tr>
                <tr>
                  <td>{{ $t('authModule.izi.lastQuery') }}</td>
                  <td>{{ creditFeatureData && creditFeatureData['create_time'] ? creditFeatureData['create_time'] : '' }}</td>
                </tr>
                <tr>
                  <td>status</td>
                  <td>{{ creditFeatureData && creditFeatureData['status'] ? creditFeatureData['status'] : '' }}</td>
                </tr>
                <tr>
                  <td>message-creditscore</td>
                  <td>
                    <span v-if="creditFeatureData && creditFeatureData['credit_score']">{{ creditFeatureData['credit_score'] }}</span>
                    <span v-if="creditFeatureData && creditFeatureData['message']">{{ creditFeatureData['message'] }}</span>
                  </td>
                </tr>
              </table>
            </el-col>
            <el-col :span="8">
              <table>
                <tr>
                  <td>{{ $t('authModule.izi.fraud') }}</td>
                  <td>
                    <el-button type="text" @click="getFraudScore(1)">
                      {{ $t('authModule.izi.click') }}
                    </el-button>
                  </td>
                </tr>
                <tr>
                  <td>{{ $t('authModule.izi.lastQuery') }}</td>
                  <td>{{ fraudData && fraudData['createTime'] ? fraudData['createTime'] : '' }}</td>
                </tr>
                <tr>
                  <td>status</td>
                  <td>{{ fraudData && fraudData['status'] ? fraudData['status'] : '' }}</td>
                </tr>
                <tr>
                  <td>message-fraud_status</td>
                  <td>
                    <span v-if="fraudData && fraudData['fraudStatus']">{{ $t('authModule.izi.fraudStatus')[fraudData['fraudStatus']] }}</span>
                    <span v-if="fraudData && fraudData['message']">{{ fraudData['message'] }}</span>
                  </td>
                </tr>
                <tr>
                  <td>message-fraud_score</td>
                  <td>{{ fraudData && fraudData['fraudScore'] ? fraudData['fraudScore'] : '' }}</td>
                </tr>
              </table>
            </el-col>
          </el-row>
        </el-collapse-item>
      </el-collapse>
    </el-card>
    <!--      人脸黑名单-星合星探-->
    <el-card>
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.faceBlackList.title') }}
          </template>
          <el-row>
            <table>
              <tr>
                <td>{{ $t('authModule.faceBlackList.faceBlack') }}</td>
                <td style="color: #80accf">
                  <el-button type="text" @click="getFaceBlacklistData(true)">
                    {{ $t('authModule.faceBlackList.click') }}
                  </el-button>
                </td>
              </tr>
              <tr v-if="faceBlacklistData && (faceBlacklistData['message'] || faceBlacklistData['isHit'] || faceBlacklistData['createTime'])">
                <td>
                  <span :style="{'color' : faceBlacklistData && faceBlacklistData['isHit']=='HIT' ? 'red' : null}">{{ faceBlacklistData['isHit'] ? faceBlacklistData['isHit'] : '' }}</span>
                  <span style="padding-left: 20px" *ngIf="faceBlacklistData['isHit']!=null && faceBlacklistData['isHit']!='HIT'">{{ faceBlacklistData['message'] ? faceBlacklistData['message'] : '' }}</span>
                </td>
                <td>
                  <span>{{ $t('authModule.faceBlackList.lastQuery') }}</span>
                  <span>{{ faceBlacklistData['createTime'] ? faceBlacklistData['createTime'] : '' }}</span>
                </td>
              </tr>
              <tr v-if="faceBlacklistData && faceBlacklistData['livenessPhotoUrl']">
                <td>
                  {{ $t('authModule.faceBlackList.photo') }}
                </td>
                <td>
                  <div style="height: 150px">
                    <el-image
                      v-if="faceBlacklistData['livenessPhotoUrl']"
                      style="width: 150px; height: 150px"
                      :src="faceBlacklistData['livenessPhotoUrl']"
                      :preview-src-list="[faceBlacklistData['livenessPhotoUrl']]"
                    />
                  </div>
                </td>
              </tr>
            </table>
          </el-row>
          <el-row v-if="faceBlacklistData && faceBlacklistData['detailVOS'] && faceBlacklistData['detailVOS'].length > 0">
            <table v-for="(item, index) in faceBlacklistData['detailVOS']" :key="index" style="margin-top: 10px">
              <tr>
                <td>
                  {{ $t('authModule.faceBlackList.score') }}
                </td>
                <td>
                  {{ item['score'] }}
                </td>
                <td>
                  LivingPhoto
                </td>
                <td>
                  CredentialPhoto
                </td>
              </tr>
              <tr>
                <td>
                  {{ $t('authModule.faceBlackList.mobile') }}
                </td>
                <td>
                  {{ item['mobile'] }}
                </td>
                <td rowspan="2">
                  <div style="height: 150px">
                    <el-image
                      v-if="item['livenessPhotoUrl']"
                      style="width: 150px; height: 150px"
                      :src="item['livenessPhotoUrl']"
                      :preview-src-list="[item['livenessPhotoUrl']]"
                    />
                  </div>
                </td>
                <td rowspan="2">
                  <div style="height: 150px">
                    <el-image
                      v-if="item['credentialPhotoUrl']"
                      style="width: 150px; height: 150px"
                      :src="item['credentialPhotoUrl']"
                      :preview-src-list="[item['credentialPhotoUrl']]"
                    />
                  </div>
                </td>
              </tr>
              <tr>
                <td>
                  {{ $t('authModule.faceBlackList.credentialNo') }}
                </td>
                <td>
                  {{ item['credentialNo'] }}
                </td>
              </tr>
            </table>
          </el-row>
        </el-collapse-item>
      </el-collapse>
    </el-card>
    <!--      快速拨号检测-->
    <el-card>
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.quickCheck.title') }}
          </template>
          <el-row v-if="Object.keys(listMsisdnData).length > 0">
            <el-button type="primary" @click="oneDetection">
              {{ $t('authModule.quickCheck.oneDetection') }}
            </el-button>
            <el-button type="primary" @click="oneRefresh">
              {{ $t('authModule.quickCheck.oneRefresh') }}
            </el-button>
            <table>
              <tr>
                <td />
                <td>{{ $t('authModule.quickCheck.phone') }}</td>
                <td>{{ $t('authModule.quickCheck.status') }}</td>
                <td>{{ $t('authModule.quickCheck.lastUpdated') }}</td>
                <td>{{ $t('authModule.quickCheck.updater') }}</td>
                <td>{{ $t('authModule.quickCheck.testResults') }}</td>
                <td>{{ $t('authModule.quickCheck.dialDetection') }}</td>
              </tr>
              <tr v-if="userAccount.length > 0">
                <td>{{ $t('authModule.quickCheck.userAccount') }}</td>
                <td>{{ userAccount[0]['phoneNumber'] }}</td>
                <td>
                  <div v-if="!listMsisdnStateData['userAccount']">
                    <span>{{ userAccount[0]['phoneNumStatus'] !== null ? $t('authModule.contactPerson.state')[userAccount[0]['phoneNumStatus']] : '' }}</span>
                    <el-button type="text" @click="edit('userAccount',userAccount[0]['phoneNumStatus'])">Edit</el-button>
                  </div>
                  <div v-if="listMsisdnStateData['userAccount']" style="width: 100%;padding: 0 10px;line-height: 30px">
                    <el-select v-model="phoneNumStatusData['userAccount']">
                      <el-option
                        v-for="item in $t('authModule.quickCheck.state')"
                        :key="item.value"
                        :label="item.desc"
                        :value="item.value"
                      />
                    </el-select>
                    <el-button type="text" @click="save('userAccount',phoneNumStatusData['userAccount'],userAccount[0])">Save</el-button>
                  </div>
                </td>
                <td>{{ userAccount[0]['modifyTime'] }}</td>
                <td>{{ userAccount[0]['modifyOperatorName'] }}</td>
                <td>
                  <span v-if="loadingState['userAccount']">
                    {{ $t('authModule.quickCheck.msisdnStatus')['99998'] }}
                  </span>
                  <span v-if="!loadingState['userAccount']">
                    {{ userAccount[0]['msisdnStatus'] !== null ? $t('authModule.quickCheck.msisdnStatus')[userAccount[0]['msisdnStatus']] : '' }}
                  </span>
                </td>
                <td>
                  <el-button type="text" @click="detection(1,userAccount[0],'userAccount')">{{ $t('authModule.quickCheck.detection') }}</el-button>
                  <el-button type="text" @click="oneRefresh">{{ $t('authModule.quickCheck.refresh') }}</el-button>
                </td>
              </tr>
              <tr v-if="companyPhone && companyPhone[0]">
                <td>{{ $t('authModule.quickCheck.companyPhone') }}</td>
                <td>{{ companyPhone[0]['phoneNumber'] }}</td>
                <td>
                  <div v-if="!listMsisdnStateData['companyPhone']">
                    {{ companyPhone[0]['phoneNumStatus'] !==null ? $t('authModule.contactPerson.state')[companyPhone[0]['phoneNumStatus']] : '' }}
                    <el-button type="text" @click="edit('companyPhone',companyPhone[0]['phoneNumStatus'])">Edit</el-button>
                  </div>
                  <div v-if="listMsisdnStateData['companyPhone']" style="width: 100%;padding: 0 10px;line-height: 30px">
                    <el-select v-model="phoneNumStatusData['companyPhone']">
                      <el-option
                        v-for="item in $t('authModule.quickCheck.state')"
                        :key="item.value"
                        :label="item.desc"
                        :value="item.value"
                      />
                    </el-select>
                    <el-button type="text" @click="save('companyPhone', phoneNumStatusData['companyPhone'], companyPhone[0])">Save</el-button>
                  </div>
                </td>
                <td>{{ companyPhone[0]['modifyTime'] }}</td>
                <td>{{ companyPhone[0]['modifyOperatorName'] }}</td>
                <td>
                  <span v-if="loadingState['companyPhone']">
                    {{ $t('authModule.quickCheck.msisdnStatus')['99998'] }}
                  </span>
                  <span v-if="!loadingState['companyPhone']">
                    {{ companyPhone[0]['msisdnStatus'] !== null ? $t('authModule.quickCheck.msisdnStatus')[companyPhone[0]['msisdnStatus']] : '' }}
                  </span>
                </td>
                <td>
                  <el-button type="text" @click="detection(2,companyPhone[0],'companyPhone')">{{ $t('authModule.quickCheck.detection') }}</el-button>
                  <el-button type="text" @click="oneRefresh">{{ $t('authModule.quickCheck.refresh') }}</el-button>
                </td>
              </tr>
            </table>
            <table v-if="listMsisdnData && listMsisdnData['userContactMsisdnVOS']" style="margin-top: 10px">
              <tr>
                <td />
                <td>{{ $t('authModule.quickCheck.relationship') }}</td>
                <td>{{ $t('authModule.quickCheck.name') }}</td>
                <td>{{ $t('authModule.quickCheck.phone') }}</td>
                <td>{{ $t('authModule.quickCheck.status') }}</td>
                <td>{{ $t('authModule.quickCheck.lastUpdated') }}</td>
                <td>{{ $t('authModule.quickCheck.updater') }}</td>
                <td>{{ $t('authModule.quickCheck.testResults') }}</td>
                <td>{{ $t('authModule.quickCheck.dialDetection') }}</td>
              </tr>
              <tr v-for="(item, index) in listMsisdnData['userContactMsisdnVOS']" :key="index">
                <td>{{ $t('authModule.quickCheck.emergency') }}{{ index + 1 }}</td>
                <td>{{ $t('authModule.quickCheck.relation')[item['relation']] }}</td>
                <td>{{ item['contactName'] }}</td>
                <td>{{ item['contactPhone'] }}</td>
                <td>
                  <div v-if="!listMsisdnStateData['relationship' + index]">
                    {{ item['phoneNumStatus'] !== null ? $t('authModule.contactPerson.state')[item['phoneNumStatus']] : '' }}
                    <el-button type="text" @click="edit('relationship' + index, item['phoneNumStatus'])">Edit</el-button>
                  </div>
                  <div v-if="listMsisdnStateData['relationship' + index]" style="width: 100%;padding: 0 10px;line-height: 30px">
                    <el-select v-model="phoneNumStatusData['relationship' + index]">
                      <el-option
                        v-for="option in $t('authModule.quickCheck.state')"
                        :key="option.value"
                        :label="option.desc"
                        :value="option.value"
                      />
                    </el-select>
                    <el-button type="text" @click="saveRelationship('relationship' + index, phoneNumStatusData['relationship' + index], item)">Save</el-button>
                  </div>
                </td>
                <td>{{ item['modifyTime'] }}</td>
                <td>{{ item['modifyOperatorName'] }}</td>
                <td>
                  <span v-if="loadingState['relationship' + index]">
                    {{ $t('authModule.quickCheck.msisdnStatus')['99998'] }}
                  </span>
                  <span v-if="!loadingState['relationship' + index]">
                    {{ item['msisdnStatus'] !== null ? $t('authModule.quickCheck.msisdnStatus')[item['msisdnStatus']] : '' }}
                  </span>
                </td>
                <td>
                  <el-button type="text" @click="detection(3, item, 'relationship' + index)">{{ $t('authModule.quickCheck.detection') }}</el-button>
                  <el-button type="text" @click="oneRefresh">{{ $t('authModule.quickCheck.refresh') }}</el-button>
                </td>
              </tr>
            </table>
          </el-row>
          <el-row>
            <p style="font-weight: bolder">{{ $t('authModule.quickCheck.manualEntry') }}</p>
            <el-divider />
            <el-input v-model="phoneDetection" type="tel" clearable :placeholder="$t('authModule.quickCheck.inputPhone')" :maxlength="20" style="width: 300px" @input="test('phoneDetection')" />
            <el-button class="left" type="primary" @click="manualEntryDetection(phoneDetection)">
              {{ $t('authModule.quickCheck.detection') }}
            </el-button>
            <table v-if="listMsisdnManualRecordData" style="margin-top: 10px">
              <tr>
                <td>{{ $t('authModule.quickCheck.phone') }}</td>
                <td>{{ $t('authModule.quickCheck.testResults') }}</td>
                <td>{{ $t('authModule.quickCheck.lastUpdated') }}</td>
                <td>{{ $t('authModule.quickCheck.dialDetection') }}</td>
              </tr>
              <tr v-for="(item,index) in listMsisdnManualRecordData" :key="index">
                <td>{{ item['msisdn'] }}</td>
                <td>{{ item['msisdnStatus'] !== null ? $t('authModule.quickCheck.msisdnStatus')[item['msisdnStatus']] : '' }}</td>
                <td>{{ item['modifyTime'] }}</td>
                <td>
                  <el-button type="text" @click="manualEntryDetection(item['msisdn'])">
                    {{ $t('authModule.quickCheck.detection') }}
                  </el-button>
                  <el-button type="text" @click="getListMsisdnManualRecordData">
                    {{ $t('authModule.quickCheck.refresh') }}
                  </el-button>
                </td>
              </tr>
            </table>
          </el-row>
        </el-collapse-item>
      </el-collapse>
    </el-card>
    <!--      自研模型调用-->
    <el-card>
      <el-collapse accordion value="1">
        <el-collapse-item name="1">
          <template slot="title">
            {{ $t('authModule.model.title') }}
          </template>
          <el-row>
            <el-button type="primary" @click="transfer(1)">
              {{ $t('authModule.model.transfer') }}
            </el-button>
            <div v-if="gradeBySelfSupport && (gradeBySelfSupport['errorMsg'] !== null || gradeBySelfSupport['errorType'] !== null)" class="left">
              <span>{{ $t('authModule.model.fail') }}</span>
              <span v-if="gradeBySelfSupport && gradeBySelfSupport['errorMsg'] !== null">{{ gradeBySelfSupport['errorMsg'] }}</span>
            </div>
            <div v-if="gradeBySelfSupport && (gradeBySelfSupport['errorMsg'] === null && gradeBySelfSupport['errorType'] === null)" class="left">
              <span>{{ $t('authModule.model.success') }}</span>
            </div>
          </el-row>
          <table>
            <tr>
              <td />
              <td>
                {{ $t('authModule.model.result') }}
              </td>
            </tr>
            <tr>
              <td>
                {{ $t('authModule.model.suggest') }}
              </td>
              <td>
                {{ gradeBySelfSupport && gradeBySelfSupport['reviewResult'] ? gradeBySelfSupport['reviewResult'] : '' }}
              </td>
            </tr>
            <tr>
              <td>
                {{ $t('authModule.model.score') }}
              </td>
              <td>
                {{ gradeBySelfSupport && gradeBySelfSupport['score'] ? gradeBySelfSupport['score'] : '' }}
              </td>
            </tr>
          </table>
        </el-collapse-item>
      </el-collapse>
    </el-card>
  </el-row>
</template>

<script>
import { xingheReport, creditScore, telecomScore, advanceInfo, bingjian, inquiriesScore, creditFeature, fraud, queryFaceBlacklist, listMsisdn, queryMsisdnStatus,
  listMsisdnManualRecord, updateUserPhoneStatus, updateUserContactStatusput, getUserGradeBySelfSupport } from '@/api/auth'
export default {
  name: 'Tripartite',
  data() {
    return {
      riskIdentificationData: [],
      creditScore: null,
      telecomScore: null,
      advanceData: {},
      bingjian: {},
      inquiriesScoreData: {},
      creditFeatureData: {},
      fraudData: {},
      faceBlacklistData: {},
      listMsisdnData: {},
      userAccount: [],
      companyPhone: [],
      listMsisdnManualRecordData: {},
      listMsisdnStateData: [],
      phoneNumStatusData: [],
      detectionStatusData: [],
      loadingState: [],
      gradeBySelfSupport: {},
      para: {},
      bingjianType: 1,
      inquiriesScoreDataType: 1,
      creditFeatureDataType: 1,
      fraudDataType: 1,
      faceBlacklistState: false,
      detectionState: false,
      phoneDetection: null
    }
  },
  mounted() {
    this.para = this.$route.query
    this.riskIdentification()
    this.getAdvanceInfo()
    this.getFaceBlacklistData(false)
    this.getListMsisdnData()
    this.getListMsisdnManualRecordData()
    this.getBingjian(0)
    this.getFraudScore(0)
    this.getCreditFeature(0)
    this.getInquiriesScore(0)
    this.transfer(0)
  },
  methods: {
    riskIdentification() {
      xingheReport(this.para.orderId)
        .then(res => {
          if (res.success) {
            this.riskIdentificationData = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getCreditScore() {
      creditScore(this.para.userId)
        .then(res => {
          this.getAdvanceInfo()
          if (res.success) {
            this.creditScore = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getTelecomScore() {
      telecomScore(this.para.userId)
        .then(res => {
          this.getAdvanceInfo()
          if (res.success) {
            this.telecomScore = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getAdvanceInfo() {
      advanceInfo(this.para.userId)
        .then(res => {
          if (res.success) {
            this.advanceData = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getBingjian(type) {
      if (this.bingjianType === 0) {
        return
      }
      const data = {
        creditOrderId: this.para.orderId,
        queryType: type
      }
      this.bingjianType = 0
      bingjian(data)
        .then(res => {
          this.bingjianType = 1
          if (res.success) {
            this.bingjian = res.data && res.data.length > 0 ? (res.data).pop() : {}
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getInquiriesScore(type) {
      if (this.inquiriesScoreDataType === 0) {
        return
      }
      const data = {
        creditOrderId: this.para.orderId,
        queryType: type
      }
      this.inquiriesScoreDataType = 0
      inquiriesScore(data)
        .then(res => {
          this.inquiriesScoreDataType = 1
          if (res.success) {
            this.bingjian = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getCreditFeature(type) {
      if (this.creditFeatureDataType === 0) {
        return
      }
      const data = {
        creditOrderId: this.para.orderId,
        queryType: type
      }
      this.creditFeatureDataType = 0
      creditFeature(data)
        .then(res => {
          this.creditFeatureDataType = 1
          if (res.success) {
            this.creditFeatureData = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getFraudScore(type) {
      if (this.fraudDataType === 0) {
        return
      }
      const data = {
        creditOrderId: this.para.orderId,
        queryType: type
      }
      this.fraudDataType = 0
      fraud(data)
        .then(res => {
          this.fraudDataType = 1
          if (res.success) {
            this.fraudData = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getFaceBlacklistData(param) {
      if (Object.keys(this.faceBlacklistData).length > 0 && this.faceBlacklistState === true) {
        return
      }
      const data = {
        queryApi: param,
        creditOrderId: this.para.orderId
      }
      queryFaceBlacklist(data)
        .then(res => {
          this.faceBlacklistState = param
          if (res.success) {
            this.faceBlacklistData = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getListMsisdnData() {
      listMsisdn(this.para.orderId)
        .then(res => {
          if (res.success) {
            this.loadingState = []
            this.listMsisdnData = res.data
            if (this.listMsisdnData && this.listMsisdnData['userMsisdnVOS']) {
              this.userAccount = this.listMsisdnData['userMsisdnVOS'].filter(v => {
                return v['phoneType'] === 1
              })
              this.companyPhone = this.listMsisdnData['userMsisdnVOS'].filter(v => {
                return v['phoneType'] === 2
              })
            }
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    oneDetection() {
      if (this.detectionState === true) {
        this.$message.error(this.$t('authModule.quickCheck.tip'))
        return
      }
      this.detectionState = true
      setTimeout(() => {
        this.detectionState = false
      }, 9000)
      this.loadingState['userAccount'] = true
      this.loadingState['companyPhone'] = true
      this.loadingState['relationship0'] = true
      this.loadingState['relationship1'] = true
      this.loadingState['relationship2'] = true
      if (this.listMsisdnData) {
        if (this.listMsisdnData['userContactMsisdnVOS']) {
          this.listMsisdnData['userContactMsisdnVOS'].forEach(v => {
            const data = {
              id: v['id'],
              phoneNumber: v['contactPhone'],
              phoneNumberType: 3,
              creditOrderId: this.para.orderId
            }
            queryMsisdnStatus(data)
              .then(res => {
                if (!res.success) {
                  this.$message.error(res.message)
                }
              })
              .catch(err => {
                this.$message.error(err.message)
              })
          })
        }
        if (this.listMsisdnData['userMsisdnVOS']) {
          this.listMsisdnData['userMsisdnVOS'].forEach(v => {
            const data = {
              id: v['id'],
              phoneNumber: v['phoneNumber'],
              phoneNumberType: v['phoneType'],
              creditOrderId: this.para.orderId
            }
            queryMsisdnStatus(data)
              .then(res => {
                if (!res.success) {
                  this.$message.error(res.message)
                }
              })
              .catch(err => {
                this.$message.error(err.message)
              })
          })
        }
      }
    },
    oneRefresh() {
      this.getListMsisdnData()
    },
    test(data) {
      let value = this[data]
      if (value.length > 0) {
        value = value.replace(/[^0-9]/g, '')
      }
      this[data] = value
    },
    detection(type, item, id) {
      if (this.detectionState === true || this.detectionStatusData[id] === true) {
        this.$message.error(this.$t('authModule.quickCheck.tip'))
        return
      }
      this.loadingState[id] = true
      this.detectionStatusData[id] = true
      setTimeout(() => {
        this.detectionStatusData[id] = false
      }, 9000)
      const data = {
        id: item['id'],
        phoneNumber: type === 3 ? item['contactPhone'] : item['phoneNumber'],
        phoneNumberType: type,
        creditOrderId: this.para.orderId
      }
      queryMsisdnStatus(data)
        .then(res => {
          if (res.success) {
            this.getListMsisdnData()
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    edit(key, data) {
      this.listMsisdnStateData[key] = true
      this.phoneNumStatusData[key] = data
    },
    save(key, value, item) {
      const data = {
        id: item['id'],
        phoneNumStatus: value,
        phoneNumberType: item['phoneType']
      }
      updateUserPhoneStatus(data)
        .then(res => {
          if (res.success) {
            this.listMsisdnStateData[key] = false
            this.getListMsisdnData()
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    saveRelationship(key, value, item) {
      const data = {
        id: item['id'],
        phoneNumStatus: value
      }
      updateUserContactStatusput(data)
        .then(res => {
          if (res.success) {
            this.listMsisdnStateData[key] = false
            this.getListMsisdnData()
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    transfer(type) {
      const data = {
        creditOrderId: this.para.orderId,
        type
      }
      getUserGradeBySelfSupport(data)
        .then(res => {
          if (res.success) {
            this.gradeBySelfSupport = res.data
          } else {
            this.gradeBySelfSupport = {}
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    manualEntryDetection(phoneNumber) {
      if (!phoneNumber) {
        return
      }
      const data = {
        phoneNumber: phoneNumber,
        phoneNumberType: 4,
        creditOrderId: this.para.orderId
      }
      queryMsisdnStatus(data)
        .then(res => {
          if (res.success) {
            this.getListMsisdnManualRecordData()
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    },
    getListMsisdnManualRecordData() {
      const data = {
        creditOrderId: this.para.orderId
      }
      listMsisdnManualRecord(data)
        .then(res => {
          if (res.success) {
            this.listMsisdnManualRecordData = res.data
          } else {
            this.$message.error(res.message)
          }
        })
        .catch(err => {
          this.$message.error(err.message)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
.left{
  margin-left: 20px;
}
.el-card{
  margin: 0 0 10px 0;
}
table{
  width: 100%;
  border-collapse: collapse;
  tr{
    width: 100%;
    text-align: center;
    td{
      height: 50px;
      border: 1px #cccccc solid;
    }
  }
}
.el-divider{
  margin: 0 0 10px 0;
}
</style>
